package models
{
	import events.CaptchaEvent;
	
	import flash.display.MovieClip;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	
	import utility.Captcha;

	public class CaptchaModel extends MovieClip
	{
		private var evtCaptcha:CaptchaEvent;
		private var clip:MovieClip;
		private var clsCaptcha:Captcha;	
		public var dataCaptcha:String;
		
		public function CaptchaModel($clip:MovieClip)
		{
			super();
			init($clip);
		}
		private function init($clip:MovieClip):void
		{
			clip=$clip;
			clsCaptcha=new Captcha(clip.width,clip.height);
			clsCaptcha.initCaptcha();
			clip.addChild(clsCaptcha);		
			// on change captcha
			clip.addEventListener(MouseEvent.CLICK,onChangeCaptcha);
		}
		public function getCaptcha():void
		{
			evtCaptcha=new CaptchaEvent("onChangeCaptcha");
			evtCaptcha.dataCaptcha=clsCaptcha.getCaptcha();
			dispatchEvent(evtCaptcha);
		}
		private function onChangeCaptcha(evt:MouseEvent):void
		{
			clsCaptcha.initCaptcha();	
		}
	}
	/* End Class */
}